<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>主页面</title>
    <script src="/webjars/jquery/3.6.0/jquery.js"></script>
    <script src="/js/js.cookie.min.js"></script>
</head>
<body>
<h3>主页面</h3>
<div>
    <input type="text" id="studentId"> <br/>
    <input type="button" id="queryBtn" value="执行查询操作">
</div>
<script>
    $(function(){
        // 检查是否已登录
        var accessToken = Cookies.get("accessToken");
        if (!accessToken) {
            alert("请先登录");
            window.location.href = "/html/loginRedis.html";
        }

        $("#queryBtn").on("click",function(){
            $.ajax({
                url:"/app/redis/query",
                type:"post",
                data:{
                    "accessToken": accessToken,
                    "id":$("#studentId").val()
                },
                dataType:"json",
                success:function(resp){
                    if (resp.code == 0) {
                        alert("查询成功：" + resp.msg);
                    } else {
                        alert("查询失败：" + resp.msg);
                    }
                },
                error: function() {
                    alert("请求失败");
                }
            })
        })
    })
</script>
</body>
</html>
